package com.dgut.cbd.exp2.practice;

import org.springframework.boot.CommandLineRunner;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import java.util.Objects;

/**
 * @Program: exp2
 * @Description:
 * @Author: cbd
 * @Create: 2021-05-05
 * @Version: 1.0.0
 **/


public class CustomCommandLineRunner implements CommandLineRunner {

    Environment environment;

    public CustomCommandLineRunner(Environment environment){
        this.environment=environment;
    }

    @Override
    public void run(String... args) throws Exception {
        System.out.println("利用springboot自动装配的CommandLineRunner");
        Thread.sleep(5000);
        System.out.println("生成一个随机字符串：".concat(Objects.requireNonNull(environment.getProperty("random."))));
    }
}
